package com.small.sentinel.slots.statistic.metric.occupy;

import com.small.sentinel.slots.statistic.base.LeapArray;
import com.small.sentinel.slots.statistic.base.WindowWrap;
import com.small.sentinel.slots.statistic.data.MetricBucket;

public class FutureBucketLeapArray extends LeapArray<MetricBucket> {
    public FutureBucketLeapArray(int sampleCount, int intervalInMs) {
        super(sampleCount, intervalInMs);
    }

    @Override
    public MetricBucket newEmptyBucket(long timeMillis) {
        return new MetricBucket();
    }

    @Override
    protected WindowWrap<MetricBucket> resetWindowTo(WindowWrap<MetricBucket> w, long startTime) {
        //重置窗口的开始时间和值
        w.resetTo(startTime);
        w.value().reset();
        return w;
    }

    @Override
    public boolean isWindowDeprecated(long time, WindowWrap<MetricBucket> windowWrap) {
        return time >= windowWrap.windowStart();
    }
}
